package com.cykj.order.util;

/**
 * Redis Key 工具类
 * 统一管理Redis中使用的key
 * 
 * @author cykj
 * @date 2025-08-20
 */
public class RedisKeyUtil {
    
    /**
     * 订单状态缓存Key
     * 格式：order:status:{orderId}
     */
    public static String getOrderStatusKey(Long orderId) {
        return "order:status:" + orderId;
    }
    
    /**
     * 订单基本信息缓存Key
     * 格式：order:info:{orderId}
     */
    public static String getOrderInfoKey(Long orderId) {
        return "order:info:" + orderId;
    }
    
    /**
     * 店铺订单列表缓存Key
     * 格式：shop:orders:{shopId}:{status}
     */
    public static String getShopOrdersKey(Long shopId, Integer status) {
        return "shop:orders:" + shopId + ":" + (status != null ? status : "all");
    }
    
    /**
     * 地区树结构缓存Key
     * 格式：region:tree:all
     */
    public static String getRegionTreeKey() {
        return "region:tree:all";
    }
    
    /**
     * 订单状态统计Key
     * 格式：shop:count:{shopId}:status:{status}
     */
    public static String getOrderStatusCountKey(Long shopId, Integer status) {
        return "shop:count:" + shopId + ":status:" + status;
    }
    
    /**
     * 用户最近订单Key
     * 格式：user:recent:orders:{userId}
     */
    public static String getUserRecentOrdersKey(Long userId) {
        return "user:recent:orders:" + userId;
    }
    
    /**
     * 订单列表查询缓存Key
     * 格式：order:list:{hashCode}
     */
    public static String getOrderListKey(String queryHash) {
        return "order:list:" + queryHash;
    }
    
    /**
     * 订单列表缓存前缀
     * 用于批量清理
     */
    public static String getOrderListKeyPrefix() {
        return "order:list:*";
    }
}
